6  NPAG with covariates

Let’s create another run object, this time using a model that include covariates.

First clone mod1.

mod2 <- mod1$clone()

Then update it to add a variable V0, or volume that depends on weight. Remove V. Note that updating changes the object in place, so we don’t have to re-assign it back to mod2, i.e. we don’t need mod2 <- mod2$update(...), although if you forget, it will work the same. Note that we also have to use the sec block to let Pmetrics know how to calculate V based on V0 and WT (weight). Here we normalize weight to the population mean of 55 kg.

mod2 <- mod2$update(
  pri = list(
    v0 = ab(30, 120),
    v = NULL
  ),
  sec = function(x) {
    v = v0*(wt/70)
  }
)
ℹ Compiling model...
Using template path: /Users/mneely/Library/CloudStorage/OneDrive-CHILDRENSHOSPITALLOSANGELES/Documents/LAPK/Development/Pmetrics_rust/inst 

Now, run that new model.

run2 <- mod2$fit(data = exData, run = 2, path = "Data/Runs", overwrite = TRUE)
[00h 00m 00s] [INFO] Objective function = 527.0641
[00h 00m 00s] [INFO] Objective function = 499.8528
[00h 00m 00s] [INFO] Objective function = 489.4649
[00h 00m 00s] [INFO] Objective function = 485.8304
[00h 00m 00s] [INFO] Objective function = 484.0783
[00h 00m 00s] [INFO] Objective function = 483.2585
[00h 00m 00s] [INFO] Objective function = 482.1890
[00h 00m 00s] [INFO] Objective function = 482.1890
[00h 00m 00s] [INFO] Objective function = 473.0736
[00h 00m 00s] [INFO] Objective function = 470.6781
[00h 00m 00s] [INFO] Objective function = 469.1795
[00h 00m 00s] [INFO] Objective function = 467.8819
[00h 00m 00s] [INFO] Objective function = 467.7910
[00h 00m 00s] [INFO] Objective function = 467.7910
[00h 00m 00s] [INFO] Objective function = 464.3140
[00h 00m 00s] [INFO] Objective function = 463.2304
[00h 00m 00s] [INFO] Objective function = 462.8099
[00h 00m 00s] [INFO] Objective function = 462.8063
[00h 00m 00s] [INFO] Objective function = 462.8063
[00h 00m 00s] [INFO] Objective function = 462.1462
[00h 00m 00s] [INFO] Objective function = 461.3525
[00h 00m 00s] [INFO] Objective function = 461.1232
[00h 00m 00s] [INFO] Objective function = 461.0404
[00h 00m 00s] [INFO] Objective function = 461.0206
[00h 00m 00s] [INFO] Objective function = 461.0206
[00h 00m 00s] [INFO] Objective function = 460.4285
[00h 00m 00s] [INFO] Objective function = 460.0191
[00h 00m 00s] [INFO] Objective function = 459.6912
[00h 00m 00s] [INFO] Objective function = 459.4123
[00h 00m 00s] [INFO] Objective function = 459.3489
[00h 00m 00s] [INFO] Objective function = 459.3085
[00h 00m 00s] [INFO] Objective function = 459.2826
[00h 00m 00s] [INFO] Objective function = 459.2738
[00h 00m 00s] [INFO] Objective function = 459.2645
[00h 00m 00s] [INFO] Objective function = 459.2514
[00h 00m 00s] [INFO] Objective function = 459.2382
[00h 00m 00s] [INFO] Objective function = 459.2285
[00h 00m 00s] [INFO] Objective function = 459.2233
[00h 00m 00s] [INFO] Objective function = 459.2121
[00h 00m 00s] [INFO] Objective function = 459.2000
[00h 00m 00s] [INFO] Objective function = 459.1854
[00h 00m 00s] [INFO] Objective function = 459.1664
[00h 00m 00s] [INFO] Objective function = 459.1515
[00h 00m 00s] [INFO] Objective function = 459.1400
[00h 00m 00s] [INFO] Objective function = 459.1322
[00h 00m 00s] [INFO] Objective function = 459.1280
[00h 00m 00s] [INFO] Objective function = 459.1274
[00h 00m 00s] [INFO] Objective function = 459.1274
[00h 00m 00s] [INFO] Objective function = 458.9680
[00h 00m 00s] [INFO] Objective function = 458.5554
[00h 00m 00s] [INFO] Objective function = 458.3744
[00h 00m 00s] [INFO] Objective function = 458.1497
[00h 00m 00s] [INFO] Objective function = 458.0299
[00h 00m 00s] [INFO] Objective function = 457.8607
[00h 00m 00s] [INFO] Objective function = 457.6091
[00h 00m 00s] [INFO] Objective function = 457.5483
[00h 00m 00s] [INFO] Objective function = 457.4484
[00h 00m 00s] [INFO] Objective function = 457.3799
[00h 00m 00s] [INFO] Objective function = 457.3003
[00h 00m 00s] [INFO] Objective function = 457.2423
[00h 00m 00s] [INFO] Objective function = 457.1790
[00h 00m 00s] [INFO] Objective function = 457.0894
[00h 00m 00s] [INFO] Objective function = 457.0678
[00h 00m 00s] [INFO] Objective function = 457.0493
[00h 00m 00s] [INFO] Objective function = 456.9887
[00h 00m 00s] [INFO] Objective function = 456.9540
[00h 00m 00s] [INFO] Objective function = 456.9427
[00h 00m 00s] [INFO] Objective function = 456.8601
[00h 00m 00s] [INFO] Objective function = 456.8469
[00h 00m 00s] [INFO] Objective function = 456.8326
[00h 00m 00s] [INFO] Objective function = 456.7597
[00h 00m 00s] [INFO] Objective function = 456.7433
[00h 00m 00s] [INFO] Objective function = 456.6816
[00h 00m 00s] [INFO] Objective function = 456.6633
[00h 00m 00s] [INFO] Objective function = 456.6437
[00h 00m 00s] [INFO] Objective function = 456.5905
[00h 00m 00s] [INFO] Objective function = 456.5705
[00h 00m 00s] [INFO] Objective function = 456.5492
[00h 00m 00s] [INFO] Objective function = 456.5032
[00h 00m 00s] [INFO] Objective function = 456.4814
[00h 00m 00s] [INFO] Objective function = 456.4598
[00h 00m 00s] [INFO] Objective function = 456.4196
[00h 00m 00s] [INFO] Objective function = 456.3951
[00h 00m 00s] [INFO] Objective function = 456.3742
[00h 00m 00s] [INFO] Objective function = 456.3513
[00h 00m 00s] [INFO] Objective function = 456.3128
[00h 00m 00s] [INFO] Objective function = 456.2900
[00h 00m 00s] [INFO] Objective function = 456.2697
[00h 00m 00s] [INFO] Objective function = 456.2342
[00h 00m 00s] [INFO] Objective function = 456.2092
[00h 00m 00s] [INFO] Objective function = 456.1873
[00h 00m 00s] [INFO] Objective function = 456.1686
[00h 00m 00s] [INFO] Objective function = 456.1316
[00h 00m 00s] [INFO] Objective function = 456.1078
[00h 00m 00s] [INFO] Objective function = 456.0875
[00h 00m 00s] [INFO] Objective function = 456.0707
[00h 00m 00s] [INFO] Objective function = 456.0515
[00h 00m 00s] [INFO] Objective function = 456.0095
[00h 00m 00s] [INFO] Objective function = 455.9907
[00h 00m 00s] [INFO] Objective function = 455.9758
[00h 00m 00s] [WARN] Maximum number of cycles reached
── Notes: ──────────────────────────────────────────────────────────────────────
• Recommend increasing `points` to at least 180 to ensure adequate coverage of
parameter space.
• Run results were saved in folder
''/Users/mneely/Library/CloudStorage/OneDrive-CHILDRENSHOSPITALLOSANGELES/Documents/LAPK/Development/Tutorial/Data/Runs/2/outputs''
• Report could not be generated.

Right after the run, the results are in run2, but for future loading if you return to your script later, you can load it with PM_load().

run2 <- PM_load(2)